import Mock from 'mockjs'
export default {
  getMenu: config => {
    const { username, password } = JSON.parse(config.body)
    console.log(JSON.parse(config.body))
    // 先判断用户是否存在
    if (username === 'admin' || username === 'xiaoguan') {
      // 判断账号和密码是否对应
      if (username === 'admin' && password === '123456') {
        return {
          code: 200,
          data: {
            menu: [
              {
                path: '/',
                name: 'home',
                title: '首页',
                icon: 's-home',
                url: 'home/home'
              },
              {
                title: "视频管理",
                icon: "video-play",
                children: [
                  {
                    path: "/addVideo",
                    name: "addVideo",
                    title: "创作视频",
                    icon: "video-camera",
                    url: "videoManAge/addVideo"
                  },
                  {
                    path: "/editVideo",
                    name: "editVideo",
                    title: "剪辑视频",
                    icon: "s-platform",
                    url: "videoManAge/editVideo"
                  },
                ],
              },
              {
                title: "用户管理",
                icon: "user",
                children: [
                  {
                    path: "/accountEdit",
                    name: "accountEdit",
                    title: "账号设置",
                    icon: "collection",
                    url: "userManAge/accountSettings"
                  },
                  {
                    path: "/informationEdit",
                    name: "informationEdit",
                    title: "信息设置",
                    icon: "chat-dot-square",
                    url: "userManAge/InformationSettings"
                  },
                ],
              },
              {
                title: "其他设置",
                icon: "s-tools",
                children: [
                  {
                    path: "/page1",
                    name: "page1",
                    title: "恢复设置",
                    icon: "setting",
                    url: "other/customerSetup"
                  },
                  {
                    path: "/page2",
                    name: "page2",
                    title: "客户设置",
                    icon: "eleme",
                    url: "other/restoreSettings"
                  },
                ],
              },
            ],
            token: Mock.Random.guid(),   //token id
            message: '获取成功'
          }
        }
      } else if (username === 'xiaoguan' && password === '123456') {
        return {
          code: 200,
          data: {
            menu: [
              {
                path: '/',
                name: 'home',
                title: '首页',
                icon: 's-home',
                url: 'home/home'
              },
              {
                title: "视频管理",
                icon: "video-play",
                children: [
                  {
                    path: "/addVideo",
                    name: "addVideo",
                    title: "创作视频",
                    icon: "video-camera",
                    url: "videoManAge/addVideo"
                  },
                  {
                    path: "/editVideo",
                    name: "editVideo",
                    title: "剪辑视频",
                    icon: "s-platform",
                    url: "videoManAge/editVideo"
                  },
                ],
              },  
              {
                title: "其他设置",
                icon: "s-tools",
                children: [
                  {
                    path: "/page1",
                    name: "page1",
                    title: "恢复设置",
                    icon: "setting",
                    url: "other/customerSetup"
                  },
                  {
                    path: "/page2",
                    name: "page2",
                    title: "客户设置",
                    icon: "eleme",
                    url: "other/restoreSettings"
                  },
                ],
              },           
            ],
            token: Mock.Random.guid(),
            message: '获取成功'
          }
        }
      } else {
        return {
          code: -999,
          data: {
            message: '密码错误'
          }
        }
      }
    } else {
      return {
        code: -999,
        data: {
          message: '用户不存在'
        }
      }
    }
  }
}
